package cn.edkuir.order.listener;

import cn.edkuir.order.service.OrderService;
import cn.edkuir.order.vo.PayAsyncVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
public class OrderPayedListener {
    @Autowired
    private OrderService orderService;


    @PostMapping("/payed/notify")
    public String handleAlipay(PayAsyncVo payAsyncVo, HttpServletRequest request) {
        //收到支付宝异步通知, 返回成功
//        Map<String, String[]> parameterMap = request.getParameterMap();
//        for (String key : parameterMap.keySet()) {
//            String value = request.getParameter(key);
//            System.out.println(key + "=>" + value);
//        }

        //验签...
        System.out.println("签名认证成功");
        //处理结果
        return orderService.handlePayResp(payAsyncVo);
    }

}
